package com.oocl.euc.core.maintenance.repository;

import com.oocl.euc.core.builder.EmailTemplateBuilder;
import com.oocl.euc.core.common.ITTestBase;
import com.oocl.euc.core.maintenance.model.EmailTemplate;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

public class EmailTemplateRepositoryIT extends ITTestBase{

    @Autowired
    EmailTemplateBuilder emailTemplateBuilder;

    @Autowired
    EmailTemplateRepository emailTemplateRepository;

    @After
    public void tearDown(){
        emailTemplateRepository.deleteAll();
    }

    @Test
    public void should_return_email_template_with_given_valid_email_template_key(){
        emailTemplateBuilder.defaultBuilder()
                .saveToDB();
        EmailTemplate emailTemplate= emailTemplateRepository.findByEmailTempalteKey(EmailTemplateBuilder.EMAIL_TEMPALTE_KEY);
        Assert.assertEquals(EmailTemplateBuilder.SEND_FROM,emailTemplate.getSendFrom());
        Assert.assertEquals(EmailTemplateBuilder.SEND_TO,emailTemplate.getSendTo());
    }

}
